#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <vector>
#include <map>
using namespace std;

typedef struct 
{
	bool white;
	char xpos, ypos;
	char name;
}cheeseT;

cheeseT mylist[50];
int tot;

int getVal(char ch)
{
	if (ch=='K') return 1;
	if (ch=='Q') return 2;
	if (ch=='R') return 3;
	if (ch=='B') return 4;
	if (ch=='N') return 5;
	if (ch=='P') return 6;
	cout << "error" << endl;
	return 0;
}

bool bigger(int a, int b)
{
	if (mylist[a].white != mylist[b].white) return false;
	
	int v1, v2;
	v1 = getVal(mylist[a].name);
	v2 = getVal(mylist[b].name);
	if (v1 != v2) return v1 > v2; // 大于就交换
	
	if (mylist[a].white == true)
	{
		if (mylist[a].ypos != mylist[b].ypos) 
			return mylist[a].ypos > mylist[b].ypos;
		return mylist[a].xpos > mylist[b].xpos;
	}
	else
	{
		if (mylist[a].ypos != mylist[b].ypos) 
			return mylist[a].ypos < mylist[b].ypos;
		return mylist[a].xpos > mylist[b].xpos;		
	}

}

void check(char ch, int y, int x)
{
	tot++;
	mylist[tot].xpos = x;
	mylist[tot].ypos = y;
	switch (ch)
	{
	case 'r': 
	case 'b': 
	case 'q': 
	case 'k': 
	case 'n': 
	case 'p': 
		mylist[tot].white = false; break;
	case 'R': 
	case 'B': 
	case 'Q': 
	case 'K': 
	case 'N': 
	case 'P': 
		mylist[tot].white = true; break;
	}
	mylist[tot].name = toupper(ch);
}

void readdata()
{
	char ss[100];
	int i, j, len;

	tot = 0;

	for (i=1; i<=17; ++i)
	{
		gets(ss);
		while (strlen(ss)==0) gets(ss);
		if (i%2 == 0)
		{	
			len = strlen(ss);
			for (j=0; j<len; ++j)
				if ( (j+2)%4==0 && ss[j]!=':' && ss[j]!='.')
					check(ss[j], 9-i/2, (j+2)/4);
		}
	}
	for (i=1; i<tot; ++i)
		for (j=i+1; j<=tot; ++j)
			if ( bigger(i,j) )
			{
				mylist[0] = mylist[i];
				mylist[i] = mylist[j];
				mylist[j] = mylist[0];
			}
}

void outone(int i)
{
	if (mylist[i].name != 'P') 
		cout <<mylist[i].name << (char)(mylist[i].xpos+'a'-1) << (char)(mylist[i].ypos+'0') ;
	else 
		cout <<(char)(mylist[i].xpos+'a'-1) << (char)(mylist[i].ypos+'0') ;
}

void output()
{
	int i, j;
	int nwhite, nblack;


	nwhite = nblack = 0;
	for (i=1; i<=tot; ++i)
		if (mylist[i].white) nwhite++;
		else nblack++;

	cout << "White: ";
	for (i=1, j=0; i<=tot; ++i)
		if (mylist[i].white)
		{
			++j;
			if (j!= nwhite)
			{
				outone(i);
				cout << ",";
			}
			else 
			{
				outone(i);
				cout << endl;
			}
		}
	cout << "Black: ";
	for (i=1, j=0; i<=tot; ++i)
		if (!mylist[i].white)
		{
			++j;
			if (j!= nblack)
			{
				outone(i);
				cout << ",";
			}
			else 
			{
				outone(i);
				cout << endl;
			}		
		}
}
int main(int argc, char* argv[])
{
    readdata();

	output();
 
    return 0;    
}    
